﻿using System;
using System.Linq.Expressions;

namespace SmartPlant.WinCore
{
    /// <summary>
    /// Linq 拓展
    /// </summary>
    public class LinqExt
    {
        /// <summary>
        /// 创建 And 表达式
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <returns>新的表达式</returns>
        public static Expression<Func<T, bool>> And<T>()
        {
            return u => true;
        }

        /// <summary>
        /// 创建 And 表达式
        /// </summary>
        /// <typeparam name="T1">泛型类型</typeparam>
        /// <typeparam name="T2">泛型类型</typeparam>
        /// <returns>新的表达式</returns>
        public static Expression<Func<T1, T2, bool>> And<T1, T2>()
        {
            return (t1, t2) => true;
        }

        /// <summary>
        /// 创建 And 表达式
        /// </summary>
        /// <typeparam name="T1">泛型类型</typeparam>
        /// <typeparam name="T2">泛型类型</typeparam>
        /// <typeparam name="T3">泛型类型</typeparam>
        /// <returns>新的表达式</returns>
        public static Expression<Func<T1, T2, T3, bool>> And<T1, T2, T3>()
        {
            return (t1, t2, t3) => true;
        }

        /// <summary>
        /// 创建 And 表达式
        /// </summary>
        /// <typeparam name="T1">泛型类型</typeparam>
        /// <typeparam name="T2">泛型类型</typeparam>
        /// <typeparam name="T3">泛型类型</typeparam>
        /// <typeparam name="T4">泛型类型</typeparam>
        /// <returns>新的表达式</returns>
        public static Expression<Func<T1, T2, T3, T4, bool>> And<T1, T2, T3, T4>()
        {
            return (t1, t2, t3, t4) => true;
        }
    }
}
